package top.korori.api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import top.korori.common.bo.MediaVideoFormBo;
import top.korori.common.model.Result;
import top.korori.common.bo.MediaPicFormBo;
import top.korori.sv.entity.vo.SvMediaVo;
import top.korori.sv.enums.SvMediaSource;
import top.korori.sv.service.SvMediaService;

/**
 * 媒体文件 前端控制器
 *
 * @author korori
 */
@Api(tags = "媒体文件")
@RestController
@RequestMapping("/sv/media")
public class SvMediaController {

    @Autowired
    private SvMediaService svMediaService;

    @ApiOperation("通用图片上传")
    @PostMapping("/uploadPic")
    public Result<SvMediaVo> uploadPic(@RequestParam(required = false) MultipartFile file, MediaPicFormBo mediaFormBo){
        SvMediaVo svMediaVo = svMediaService.uploadPic(file,mediaFormBo, SvMediaSource.FRONT.getSource());
        return Result.ok(svMediaVo);
    }

    @ApiOperation("Base64图片上传")
    @PostMapping("/uploadBase64Pic")
    public Result<SvMediaVo> uploadBase64Pic(@RequestBody MediaPicFormBo mediaFormBo){
        SvMediaVo svMediaVo = svMediaService.uploadBase64Pic(mediaFormBo, SvMediaSource.FRONT.getSource());
        return Result.ok(svMediaVo);
    }

    @ApiOperation("通用视频上传")
    @PostMapping("/uploadVideo")
    public Result<SvMediaVo> uploadVideo(@RequestParam MultipartFile file, MediaVideoFormBo mediaFormBo){
        SvMediaVo svMediaVo = svMediaService.uploadVideo(file,mediaFormBo, SvMediaSource.FRONT.getSource());
        return Result.ok(svMediaVo);
    }

}














